<?php
class DbCommand
{
	function insertCommand($table, $parameters)
	{
		$command = "INSERT INTO ".$table." VALUES(null,".$parameters.")";
		$this->ExecCommand($command);		
		mysql_close();
	}
	
	function updateCommand($table, $parameters, $id)
	{
		$command = "UPDATE ".$table." SET ".$parameters." WHERE id = ".$id;
		$this->ExecCommand($command);
		
		mysql_close();
	}
	
	function selectCommand($table, $id)
	{
		$command = "SELECT * FROM ".$table." WHERE id = ".$id;
		return $this->ExecCommand($command);
	}
	
	function searchCommand($options, $table, $method, $parameters)
	{
		$command = "SELECT ".$options." FROM ".$table." ".$method." ".$parameters."";
		return $this->ExecCommand($command);
	}
	
	function deleteCommand($table, $id){	
		$command = "DELETE FROM ".$table." WHERE id = ".$id;
		$this->ExecCommand($command);
		
		mysql_close();
	}
	
	function listCommand($table,$fields, $options)
	{
		$command = "SELECT ".$fields." FROM ".$table."  ".$options;
        //die($command);
		return $this->ExecCommand($command);
	}
	
	function ExecCommand($command)
	{
		$result =  mysql_query($command) or die(mysql_error());

		return $result;
	}
}